package com.definity.toolkit.ui.action;

import java.util.HashMap;
import java.util.Map;

public class ProcessManagerFactory {

	private static Map<String, ProcessManager> managers = new HashMap<String, ProcessManager>();
	
	private ProcessManagerFactory() {

	}
	
	public static synchronized final ProcessManager getProcessManager(String name) {
		ProcessManager processManager = managers.get(name);
		if (processManager == null) {
			processManager = new ProcessManager(name);
			managers.put(processManager.getName(), processManager);
		}
		return processManager;
	}
	
	public static synchronized final void destroy(String name) {
		ProcessManager processManager = managers.get(name);
		if (processManager == null)
			return;
		
		managers.remove(name);
		processManager.killAll();
	}
	
}
